<template>
	<div>
		<sys-user-search @search="onSearch" />
		<el-card class="box-card">
			<div slot="header" class="clearfix">
				<div>
					<span style="float: left; ">用户管理</span>
					<el-button style="float: right; padding: 3px 0" type="text" @click="onCreate">新建</el-button>
				</div>
			</div>
			<sys-user-table style="width:100%" ref="table" @update-record="onUpdate"/>
		</el-card>
		<sys-user-create :visible.sync="createFormVisible" @submit-success="onSubmitSuccess"/>
		<sys-user-update :visible.sync="updateFormVisible" @submit-success="onSubmitSuccess" ref="updateForm" />
	</div>
</template>

<script>
	import SysUserTable from "./table.vue"
	import SysUserSearch from "./search.vue"
	import SysUserCreate from "./create.vue"
	import SysUserUpdate from "./update.vue"
	export default {
		name: 'user',
		components: {
			SysUserTable,
			SysUserSearch,
			SysUserCreate,
			SysUserUpdate,
		},
		data() {
      return {
				createFormVisible: false,
				updateFormVisible: false,
      }
    },
		methods: {
			onSearch(searchForm) {
				console.log('searchForm', searchForm)
			},
			onCreate() {
				this.createFormVisible = true;
			},
			onUpdate(id) {
				this.updateFormVisible = true;
				this.$refs.updateForm.loadData(id);
			},
			onSubmitSuccess() {
				console.log('onSubmitSuccess');
				this.$refs.table.loadList();
			},
		}
	}
</script>

<style>
  .text {
    font-size: 14px;
  }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }

  .box-card {
    width: 100%;
  }
</style>
